<template>
  <div id="app">
    <!--<el-row class="top-row">
      <el-col :span="12" class="top-col">
        <div class="grid-content bg-purple">
          <img src="./assets/logo/byyl-logo1.png" class="logoImg"/>
        </div>
      </el-col>
      <div v-if="isLogin">
        <el-col :span="1" :offset="offsetVale" class="grid-content-profile top-col">
          <div class="navDiv">
            <img src="./assets/images/antOutline-bell.svg" class="messageImg">
          </div>
        </el-col>
        <el-col :span="1" class="grid-content-profile top-col">
          <el-dropdown class="avatar-container right-menu-item hover-effect" trigger="click">
            <div>
              <img :src="avatarFilePath" class="profileImg">
            </div>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item divided @click.native="logout">
                <span>退出登录</span>
              </el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </el-col>
        <el-col :span="2" class="top-col">
          <div>
            <span class="profileSpan">用户名：{{user.userName}}</span>
          </div>
        </el-col>
      </div>
    </el-row>-->
    <router-view/>
  </div>
</template>

<script>
  import Cookies from "js-cookie";
  import {getInfo} from '@/api/login';

  export default {
    name: 'App',
    data() {
      return {
        avatarFilePath:'',
        isLogin: false,
        offsetVale: 8,
        username:'',
        user:{}
      };
    },
    methods: {
      async logout() {
        this.$confirm('确定注销并退出系统吗？', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.removeToken();
          sessionStorage.clear();
          location.href = '/';
        })
      }
    },
    created() {
      const adminToken = this.getToken();
      const user = this.getDataFromCookie("user");
      console.log('admin-center-token='+adminToken);
      console.log(user,"user");
      if(adminToken){
        this.isLogin = true;
        // 获得用户信息
        getInfo().then(response=>{
          console.log("主页-获得用户信息");
          console.log(response);
          if(response.code==0){
            this.user = response.data;
            // 头像  response.data.avatarFilePath
            let filePath = this.downloadServer+response.data.avatarFilePath;
            this.avatarFilePath = response.data.avatarFilePath?filePath:require("@/assets/images/profile.png");
            console.log(this.avatarFilePath,'this.avatarFilePath')
          }
        });
      }else{
        this.isLogin = false;
      }
    },
    mounted(){
      console.log(window.screen.availHeight,"window.screen.availHeight")
      //设置浏览器的高度
      document.getElementById("app").style.height = (window.screen.availHeight-100)+"px";
    }
  }
</script>

<style>
  .avatar-container {
    margin-right: 30px;
  }
  .right-menu-item {
    display: inline-block;
    padding: 0 8px;
    height: 100%;
    font-size: 18px;
    color: #5a5e66;
    vertical-align: text-bottom;
  }
  .hover-effect {
    cursor: pointer;
    transition: background .3s;
  }
  .hover-effect:hover {
    background: rgba(0, 0, 0, .025)
  }

  body {
    background-color: #F0F0F0;
    border:1px solid #C3C3C3;
    overflow: hidden;
  }

  #app {
    font-family: 'Avenir', Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    color: #2c3e50;
    margin-top: 0px;
    background-color: #F0F0F0;
  }

  .top-row {
    margin-bottom: 20px;
    border: 1px solid #C3C3C3;
  }

  .top-col {
    margin-top: 10px;
    border-radius: 4px;
  }

  .bg-purple-dark {
    /*background: #99a9bf;*/
  }

  .grid-content {
    border-radius: 4px;
    min-height: 36px;
  }

  .grid-content .logoImg {
    width: 150px;
    padding-left: 20px;
  }

  .bg-purple {
    /*background: #d3dce6;*/
  }

  .navDiv {
    line-height: 40px;
  }

  .messageImg {
    height: 25px;
    width: 25px;
  }

  .profileImg {
    height: 35px;
    width: 35px;
    border-radius: 35px;
  }

  .profileSpan {
    font-size: 13px;
    display: inline-block;
    line-height: 35px;
    margin-left: 10px;
  }

  .grid-content-profile {
    width: 40px;
  }
</style>
